home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / BASIC / 0006.ZIP / COVER.DOC < prev    next >
Text File  |  1983-06-16  |  13KB  |  265 lines

  1.  
  2.  
  3.  
  4.                    SORTED DISKETTE DIRECTORY LISTING - IBM PC
  5.  
  6.              Just what you always needed!   Yet another redundant, dupli-
  7.         cative,  and space occupying utility...  Hopefully,  this fills a 
  8.         nitch left open in the array of PC-DOS utilities.  This one sorts 
  9.         and formats the directory data and prints it so its "just  right" 
  10.         to  fit inside the diskette envelope.   You have to provide  your 
  11.         own paper cutter... the utility does the rest.  
  12.  
  13.              The program runs under PC-DOS Versions 1.x or 2.0,  and will 
  14.         operate  on any normal configuration.   It does expect the IBM or 
  15.         Epson MX80 printer (or equivalent), but should be easily modified 
  16.         to apply to any printer that offers "condensed" print and 8 lines 
  17.         per inch line spacing.   It is written in Assembler,  but uses no 
  18.         macros,  so either ASM or MASM can be used to assemble the source 
  19.         code.  LINK and EXE2BIN are required.
  20.  
  21.              It has two known limitations.   It ignores hidden files, and 
  22.         if  you're  a Version 2.0 user and have  implemented  the  "tree" 
  23.         directory  paths  with mulitple directories on  a  diskette,  the 
  24.         subordinate  directories will also be ignored.   Since the "path" 
  25.         logic  seems primarily aimed at fixed disk,  and this utility  is 
  26.         directed towards diskettes,  these limitations should not  effect 
  27.         most  users.   Someday I'll get rich,  and get a fixed disk,  but 
  28.         till then....
  29.  
  30.              The utility resulted from a scenario in which I found myself 
  31.         a frequent player.   I hope I'm alone in the world, but I suspect 
  32.         I'm not.   The scenario goes like this...  Phone rings.  Voice on 
  33.         the line says, "Say Dan, you know that program that puts a double 
  34.         whammy  on the singlefritz when you've juiced  the  slobert?   My 
  35.         only copy got clobbered, so would you check and see if you've got 
  36.         a  backup?"  Well,  I've got something in excess of 200 diskettes 
  37.         neatly filed in boxes,  labeled correctly, etc.  The only problem 
  38.         is that a label which says "Miscelaneous Junk Utilities" may have 
  39.         meant  something when I wrote it,  but it sure doesn't mean  much 
  40.         now.   Next step is to break in to what ever is currently running 
  41.         on the PC, and start sticking in diskettes to do a DIR to check.
  42.  
  43.              Actually  this  kind of event led to my writing a  "Catalog" 
  44.         facility (which does everything but cook) for the PC,  but  after 
  45.         some  months  of use,  I found that the part of  this  relatively 
  46.         large  and  complex package that I really used,  was this  simple 
  47.         print utility.   So I "extracted" that portion of the big  system 
  48.         to  pass on to the rest of the world.   I'm placing this code  in 
  49.         "Public Domain", so use it as you will.
  50.  
  51.              The  program  is  called "COVER" and is  composed  of  seven 
  52.         separately  assembled modules:  COVER,  COTITL,  COFREE,  COSCAN, 
  53.         COSORT, COPRNT, and COENDP.  The listings are commented, but I'll 
  54.         include a few words on each of the modules.   
  55.  
  56.              COVER  is  the main control module,  and contains the  major 
  57.         loop.   Its first action is to preset the printer to 8 lines  per 
  58.         inch,  condensed  print,  and  a  44 line page.   If you  have  a 
  59.  
  60.  
  61.                                         1
  62.  
  63.  
  64.  
  65.  
  66.  
  67.         Diskette Directory Listing
  68.  
  69.  
  70.         "different"  printer,  you may need to change the control  stream 
  71.         defined at SETPRT.   The final zero in the control stream is  not 
  72.         sent to the printer, but marks the end of string for DOPRT.
  73.  
  74.              Next, COVER checks for the DOS Version.  The return from the 
  75.         30H  call  (which is valid on release 1.x),  is the  release  and 
  76.         version numbers under V2.0 of DOS.   On prior releases it returns 
  77.         a  zero.   This  code  simply sets a switch that will  be  tested 
  78.         later.   The  "default" drive is then determined and  saved,  and 
  79.         finally, the number of drives on the configuration is determined.
  80.  
  81.              COVER  then  prompts  for the drive  letter  for  the  drive 
  82.         containing the diskette to be listed.  The single character input 
  83.         is first checked for an "Escape" (all done, so get off), and then 
  84.         the  drive character is verified for a "legal" drive  designator.  
  85.         The prompt starts the main loop,  which ends after all processing 
  86.         is  done for one diskette.   COVER then calls GETTTL (Get Title), 
  87.         GETFRE  (Determine  free  space  on  diskette),  SCAN  (Load  all 
  88.         directory  entries into an internal stack),  SORT  (Sequence  the 
  89.         stacked entries), and PRINT (which formats and prints the stacked 
  90.         entries).   Each  of the called routines will be mentioned in the 
  91.         following paragraphs.
  92.  
  93.              When  the Escape character is sensed,  COVER forces  a  page 
  94.         restore  to  complete the current listing,  resets the  "default" 
  95.         drive  to its value on entry,  conditionally forces out one  more 
  96.         "page"  to restore the paper to the true top of forms,  and  then 
  97.         resets the printer to "power up" status.   The control string for 
  98.         the  latter  is at RESPRT so the "different"  printer  users  may 
  99.         modify that string if required.  
  100.  
  101.              GETTTL  is a primitive module which solicits a "title"  from 
  102.         the  user.   Forty characters are allowed,  and the standard  DOS 
  103.         function is used to get this string.  Nul titles are permissable.  
  104.         The DOS function is also used to get the system date.   DECMAL is 
  105.         a  local  subroutine  that coverts the content of the AL  to  two 
  106.         decimal digits in the AH and AL and then stores them in the  area 
  107.         defined by the DI register.  
  108.  
  109.              GETFRE  computes the "free" space available on the  diskette 
  110.         and  places  the ASCII decimal result in the  title  line.   This 
  111.         program  is the reason COVER checked for the DOS  Version.   V2.0 
  112.         provides  a  "nice"  function  that  will  give  the  free  space 
  113.         directly,  but  does not allow you to gain addressability to  the 
  114.         File Allocation Table (FAT).  V1.x did not have this feature, but 
  115.         did provide addressability to the FAT.  Since this program was to 
  116.         be used in both environments,  this code has two paths.  The code 
  117.         following  the version test is for V2.0.   Code starting  at  the 
  118.         label  VERS1  is that process necessary to determine  free  space 
  119.         under the older versions of DOS.   VCOM marks the point where the 
  120.         two paths re-join.  If you're only running V2.0, you can decrease 
  121.         the size of the utility by removing the code from the instruction 
  122.         "JMP VCOM" to the instruction before that labeled VCOM.  Finally, 
  123.         CONVRT  is a public subroutine that converts the AX/DX content to 
  124.         a max of a six digit number,  leading zero surpressed, and places 
  125.  
  126.  
  127.                                         2
  128.  
  129.  
  130.  
  131.  
  132.  
  133.         Diskette Directory Listing
  134.  
  135.  
  136.         the result at the area pointed to by the DI register.  
  137.  
  138.              SCAN  does  the normal DOS function calls to "find"  an  all 
  139.         "wild  card" file name.   This process repeats until  the  entire 
  140.         directory has been scanned.   The result is placed in a stack and 
  141.         a  pointer to the start of the entry is placed in a pointer list.  
  142.         The format of the stack entries is the file-name.typ followed  by 
  143.         a  zero  byte,  and then the four byte file size field  from  the 
  144.         directory.  Since the data transfer area (DTA) has not been reset 
  145.         this  module  finds  it input in the default DTA at  80H  in  the 
  146.         program prefix.  
  147.  
  148.              SORT  is a simple "bubble" sort of the stacked entries,  but 
  149.         is  driven from the pointer list.   Yes,  I know a shell sort  is 
  150.         faster,  but  for a max of 112 entries,  an old fashioned  bubble 
  151.         uses less memory!  
  152.  
  153.              PRINT  simply  uses the sorted pointers to  form  the  final 
  154.         output.   The  title  line has already been formed by  the  prior 
  155.         modules.   The  local subroutine PRTENT uses CONVRT to format the 
  156.         file  sizes.   Four  columns  will "fit" within  the  print  size 
  157.         required,  so PRINT initially computes column length.   An inner 
  158.         and  an outer loop controls the print process.   The  inner  loop 
  159.         prints  one entry each execution,  and is executed four times per 
  160.         line.   The  outer  loop  is cycled once per entry  in  a  single 
  161.         column.  
  162.  
  163.              The  source  module COENDP includes no  code.   This  module 
  164.         simply  provides  addressability to the memory above the  program 
  165.         code.   V2.0  provides this function in a much "cleaner"  manner, 
  166.         but  since  this  utility  is to  run  on  either  Version,  this 
  167.         subterfuge is necessary.
  168.  
  169.              That's  a  very  quick "walk  through"  for  the  code,  but 
  170.         together  with the source comments,  it should provide  sufficent 
  171.         information for any extensions or modifications you may choose to 
  172.         make.   Key the source in,  and assemble the seven modules.   The 
  173.         Link  control stream is also included in the listings.   Be  very 
  174.         sure that the module COENDP occurs last in the control stream, as 
  175.         shown  in  the listing.   Otherwise you'll be stacking  directory 
  176.         entries over some of the code.  
  177.  
  178.              For those of you who are not familiar with "COM" files,  ALL 
  179.         segment  registers are preset by the operating system to the same 
  180.         value,  so  although  you see no code for setting the DS  and  ES 
  181.         segment registers,  they contain the same value as the CS and  SS 
  182.         at  program initiation so change is not required.   The stack  is 
  183.         automatically  allocated  at the "top" of the segment  (64K)  the 
  184.         program  is  loaded to,  so no stack establishment  is  required.  
  185.         Finally,  the  established stack is initialized so that a  "NEAR" 
  186.         return  at  end of program will return you to DOS  correctly,  so 
  187.         long as the CS register has not been changed.   This program uses 
  188.         the 20H termination call, but could do a simple near RET with the 
  189.         same result.
  190.  
  191.  
  192.  
  193.                                         3
  194.  
  195.  
  196.  
  197.  
  198.  
  199.         Diskette Directory Listing
  200.  
  201.  
  202.              Link  will provide console messages saying that there is  no 
  203.         stack segment (that's right), and that there is one error (that's 
  204.         false).   This  response is normal when you're preparing a  "COM" 
  205.         file.   If you get more errors or other indications, you'd better 
  206.         re-check your work.
  207.  
  208.              Now  you're  ready  to  run EXE2BIN,  and  then  rename  the 
  209.         resultant  file (COVER.BIN) to COVER.COM.   That's all it  takes.  
  210.         The utility will prompt with a console message asking which drive 
  211.         contains the diskette to be listed, so enter the single character 
  212.         drive designator appropriate (A-G).   No colon or carriage return 
  213.         will be required.  The program will then prompt for the title you 
  214.         wish  to appear on the top line of the list.   A forty  character 
  215.         field is provided.   If you do not want the title, simply hit the 
  216.         "Enter" key, and the top line of the listing will be blank except 
  217.         for the date.   When the first listing is complete,  the  utility 
  218.         will loop back and ask for another drive.  This iterative process 
  219.         will  continue until you repond with an "Escape" key to the drive 
  220.         request prompt.  Exit is then made to the DOS.  
  221.  
  222.              Note  that although the utility prints two  envelope  covers 
  223.         per page, forms will be advanced to the "top of form" position in 
  224.         effect  when the utility was started.   The printer will also  be 
  225.         restored to "power up" status.   If you use Control-Break to exit 
  226.         the  utility,  this will not be true,  so you'll have to manually 
  227.         re-aline and reset your printer.  
  228.  
  229.              There's not that much code in this utility,  but as  always, 
  230.         if you don't want to "poke" this in yourself, send me a diskette, 
  231.         with mailer and postage, and I'll copy my source and return it to 
  232.         you,  or  if you prefer,  send me a check for $7.50 and I'll send 
  233.         you a new diskette (single surface - 8 sector).   You can contact 
  234.         me at the address or phone given below:
  235.  
  236.                   Dan Daetwyler
  237.                   Route 5, Box 518A
  238.                   Springdale, Arkansas 72764
  239.                   501-756-0212
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.                                         4
  260.  
  261.  
  262.  
  263.  
  264.  
  265.